//引入字体图标
require('../../assets/public/fonts/iconfont.css')
//渲染tabbar函数
function renderTabbar(pathname) {
    //获取当前地址
    // console.log('location.pathname :>> ', location.pathname)

    let arr = [
        {
            path: './home.html',
            title: '首页',
            icon: 'icon-shouye',
        },
        {
            path: './run.html',
            title: '运动',
            icon: 'icon-24gl-heartPulse',
        },
        {
            path: './circle.html',
            title: '圈子',
            icon: 'icon-quanzi',
        },
        {
            path: './mine.html',
            title: '我的',
            icon: 'icon-yonghu',
        },
    ]
    let html = `
    ${arr.map((v, i) => {
        return ` <div class="nav df fdc jcc ">
                        <a href="${v.path}"  class="iconfont ${v.icon}  ${v.path === `./${pathname}.html` && 'active'}"></a>
                        <a href="${v.path}" class="navText  ${v.path === `./${pathname}.html` && 'active'}">${v.title}</a>
                 </div>
                         `
    }).join('')}
    `
    //创建一个footer
    let footer = document.createElement('footer')
    //设置footer的class
    footer.className = 'tabbar df jcsa fn'
    //给div里面填充内容
    footer.innerHTML = html
    //body把div添加进最后
    document.body.appendChild(footer)
}

//导出tabbar渲染函数
module.exports = renderTabbar
